package org.example.day03;

/**
 * 第二章节2.1.6:synchronized锁重入
 *      《可重入锁》某线程获取到某对象锁，没释放时，再次获取，还是可以获取到。如果不可重入，则发生死锁。
 **/
public class MyThread8 {
    synchronized public void service1(){
        System.out.println("service1");
        service2();
    }
    synchronized public void service2(){
        System.out.println("service2");
        service3();
    }
    synchronized public void service3(){
        System.out.println("service3");
    }

    public static void main(String[] args) {
        Thread8A t8 = new Thread8A();
        t8.start();
    }
}

class Thread8A extends Thread{
    @Override
    public void run() {
        MyThread8 m8 = new MyThread8();
        m8.service1();
    }
}